﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace IPfiri
{
    class Program
    {
        static void Main(string[] args)
        {

            Console.WriteLine("Add new client(yes/no)");
            string add = Console.ReadLine();
            
            while (add == "yes")
            {
                Console.WriteLine("Info:");
                
                Console.WriteLine("-> Client name:");
                string nume = Console.ReadLine();
                
                Console.WriteLine("-> Client age:");
                string varsta = Console.ReadLine();

                Client c = ClientPool.Instance.extractFromPool(nume, varsta);

                Console.WriteLine("___________________________________________");

                Console.WriteLine("Add car(yes/no)");
                string addCar= Console.ReadLine();
                
                while (addCar == "yes")
                {

                    Console.WriteLine("Configure your car!");
                    
                    Console.WriteLine("->     Transmission:");
                    string transmisie = Console.ReadLine();
                    
                    Console.WriteLine("->     Color:");
                    string culoare = Console.ReadLine();

                    Console.WriteLine("->     Type = s/m/c");
                    string tip = Console.ReadLine();

                    Console.WriteLine("->    Options :");
                    string dotari;
                    dotari = Console.ReadLine();

                    Console.WriteLine("->     Specific size:");
                    string dimensiuni;
                    dimensiuni = Console.ReadLine();

                    Console.WriteLine("->     Motor:");
                    string motorizare;
                    motorizare = Console.ReadLine();

                    Console.WriteLine("___________________________________________");

                    Car m = null;
                    if (tip == "s")
                    {
                        AbstractFactory factory;
                        factory = new ConcreteFactory3();
                        
                        SedanCar car = (SedanCar)factory.createProduct();
                        
                        car.setCuloare(culoare);
                        car.setDimensiuni(dimensiuni);
                        car.setDotari(dotari);
                        car.setMotorizare(motorizare);
                        car.setTransmisie(transmisie);
                        
                        c.addCar(car);
                        
                    }
                    else
                        if (tip == "c")
                        {
                            AbstractFactory factory;
                            factory = new ConcreteFactory1();

                            CoupeCar car = (CoupeCar)factory.createProduct();

                            car.setCuloare(culoare);
                            car.setDimensiuni(dimensiuni);
                            car.setDotari(dotari);
                            car.setMotorizare(motorizare);
                            car.setTransmisie(transmisie);

                            c.addCar(car);
                        }
                        else
                            if (tip == "m")
                            {
                                AbstractFactory factory;
                                factory = new ConcreteFactory2();

                                MiniCar car = (MiniCar)factory.createProduct();

                                car.setCuloare(culoare);
                                car.setDimensiuni(dimensiuni);
                                car.setDotari(dotari);
                                car.setMotorizare(motorizare);
                                car.setTransmisie(transmisie);

                                c.addCar(car);
                            }
                           
                         Console.WriteLine("___________________________________________");
                         Console.WriteLine("_________________SUCCESS!__________________");
                         Console.WriteLine("___________________________________________");
                   
                    Console.WriteLine("Add new car (yes/no):");
                    addCar = Console.ReadLine();
            
                    }
                    
                    Console.WriteLine("___________________________________________");

                    Console.WriteLine("Show all cars(yes/no):");
                    string afisazaMasini = Console.ReadLine();
                    if (afisazaMasini == "yes")
                     {
                         c.showCars();
                     }
                    
                    Console.WriteLine("___________________________________________");
                    Console.WriteLine("Add new client(yes/no)");
                     add = Console.ReadLine();
                }
                

              
               
            }
            

        }
        
    }
